package com.xqh.javabasic.input_output_device;
import java.io.FileOutputStream;
public class Arr_SaveIntToFile_MoveBit_BitAnd{
		
	public static void arr_SaveIntToFile_MoveBit_BitAnd(int [] arr)throws Exception{
		FileOutputStream  fos =new FileOutputStream("d:/data1");
		
		byte b3,b2,b1,b0;
		int x = 0;
	while(x < arr.length){
	
			b0 = (byte)(arr[x]) ;
			b1 = (byte)((arr[x] & 0b00000000000000001111111100000000) >> 1 * 8);
			b2 = (byte)((arr[x] & 0b00000000111111110000000000000000) >> 2 * 8);
			b3 = (byte)((arr[x] & 0b11111111000000000000000000000000) >> 3 * 8);
		
		fos.write(b3);
		fos.write(b2);
		fos.write(b1);
		fos.write(b0);
		x++;
		}
	fos.close();
		
	}
public static void main(String [] args)throws Exception{

		int [] arr = {9,89,35,64,88,906};
		arr_SaveIntToFile_MoveBit_BitAnd(arr);
		
	}
}		

